import * as utils from '../index.js'

const col = {
	get(arr, subGroupLength) {
		arr = arr || []
		subGroupLength = subGroupLength || 4
		if (arr == 0) return []
		let index = 0
		let newArray = []
		while (index < arr.length) {
			newArray.push(arr.slice(index, index += subGroupLength));
		}
		// 最后一位缺几个补全
		let lengthAll = subGroupLength - newArray[newArray.length - 1].length
		for (let i = 0; i < lengthAll; i++) {
			let objTmp = {}
			Object.keys(arr[0]).map((item) => {
				objTmp[item] = item == 'id' ? utils.newGuid.get() : ''
			})
			newArray[newArray.length - 1].push(objTmp)
		}
		return newArray
	},
}

module.exports = col